import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-07-21
 * Time: 10:04
 */
public class DeleteBooks implements Port{
    @Override
    public void work(BookList bookList) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你要删去的书名");
        String name=scanner.nextLine();
        int size=bookList.getUserSize();
        for(int i=0;i<size;i++){
            Book book=bookList.getBooks(i);
            if (book.getName().equals(name)){
                for (int j = i+1; j < size; j++) {
                    book=bookList.getBooks(j);
                    bookList.setBooks(book,j-1);
                }
                //改书籍数量
                size--;
                bookList.setUserSize(size);
                return;
            }
        }
    }
}
